#include"Sort.h"


void InsertSort(int* a, int siz) {
	for (int i = 0; i <siz-1; i++) {
		int end = i;
		int tmp = a[end+1];
		while (end > 0) {
			if (tmp < a[end]) {
				a[end + 1] = a[end];
				end--;
			}
			else {
				break;
			}
		}
		a[end+1] = tmp;
	}
}
void print(int* a, int siz) {
	for (int i = 0; i < siz; i++) {
		printf("%d ", a[i]);
	}
}
void ShellSort(int* a, int siz) {
	int gap = siz;

	while (gap>1){
		gap = gap / 3 + 1;
		for (int i=0;i<siz-gap;i++) {
			int end=i;
			int tmp = a[gap + end];
			while (end > 0) {
				if (tmp < a[end]) {
					a[gap + end] = a[end];
					end -= gap;
				}
				else {
					break;
				}
			}
			a[end + gap] = tmp;
		}
	}

}